package com.toocms.jinjuhang.ui.mine.certification

import android.app.Application
import androidx.databinding.ObservableArrayList
import androidx.databinding.ObservableField
import com.toocms.jinjuhang.R
import com.toocms.jinjuhang.BR
import com.toocms.jinjuhang.config.Urls
import com.toocms.jinjuhang.data.system.LicenseData
import com.toocms.jinjuhang.widget.view_model.requestData
import com.toocms.tab.base.BaseModel
import com.toocms.tab.base.BaseViewModel
import com.toocms.tab.binding.ItemBinding

class CertificationModel(application: Application) : BaseViewModel<BaseModel>(application) {
    val items = ObservableArrayList<CertificationItemModel>()
    val itemBinding = ItemBinding.of<CertificationItemModel>(
        BR.certificationItemModel,
        R.layout.item_certification
    )

    init {
        requestData(Urls.System.LICENSE, resultClass = LicenseData::class.java, result = {
            it.list?.forEach { item ->
                items += CertificationItemModel(this, it.list, ObservableField(item))
            }
        })

    }
}